<template>
  <div class="jfcl" style="width: 80%;">
    <h2>退款纠纷处理</h2>
    <el-form ref="form" :model="form" :rules="rules" label-width="100px">
      <el-form-item label="判定支持" prop="zc">
        <el-radio-group v-model="form.zc">
          <el-radio label="支持买家">支持买家</el-radio>
          <el-radio label="支持商家">支持商家</el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="处理原因" prop="reason">
        <el-select v-model="form.reason">
          <el-option label="请选择原因" value=""></el-option>
          <el-option label="商家在理" value="商家在理"></el-option>
          <el-option label="客户在理" value="客户在理"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="补充说明" prop="bcsm">
        <el-input type="textarea" v-model="form.bcsm"></el-input>
      </el-form-item>
      <el-form-item label="上传证明" prop="url">
        <el-upload
            action="http://localhost:8000/xm-trade/order/fileUpload"
            :on-change="handleChange"
            :before-upload="beforeUpload"
            :file-list="fileList"
            :limit="1">
          <el-button size="small" type="primary">选择文件</el-button>
        </el-upload>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="submitForm">确定</el-button>
        <el-button @click="resetForm">取消</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  data() {
    return {
      id: '',
      form: {
        decision: '',
        reason: '',
        description: '',
        proof: ''
      },
      rules: {
        // 表单验证规则
      },
      fileList: null,
    };
  },
  methods: {
    submitForm() {
      this.form.oid=this.id
      this.form.username="审核员"
      this.form.role=2
      this.$refs.form.validate((valid) => {
        if (valid) {
          // 提交表单数据的逻辑
          this.axios.post(`http://localhost:8000/xm-trade/xm-refund/save`, this.form).then(res => {
            if (res.data.code == 200) {
              // this.$router.push('/orderrefund')
              this.$message({
                message: '处理成功',
                type: 'success'
              })
              this.$router.push('/orderrefund')
            } else {
              this.$message({
                message: '处理失败',
                type: 'error'
              })
            }
          })
        } else {
          console.log('表单验证失败');
          return false;
        }
      });
    },
    resetForm() {
      this.$refs.form.resetFields();
    },
    handleChange(file, fileList) {
      this.fileList = fileList;
      this.form.url=file.response
      console.log(this.form.url)
    },
    beforeUpload(file) {
      // 文件上传前的处理逻辑
      return true;
    }
  },
  created() {
    // 组件创建时的逻辑
    this.id=localStorage.getItem("id")
  }
};
</script>
